/**
 * Created by DELL on 2017/6/23.
 */
common.buildNormalEnumSelect(".verifyStatus", enumObject.enumJsonData['verifyStatus']);//创建 审核状态 枚举列表
/**
 * 中介联系人 列表初始化设置
 * @type {Object}
 */
var settings = {
    "sAjaxSource": window.globalHost + common.houseVisitedRecordListPath,
    "aoColumns": [{
        "mDataProp": function(obj) {
            // return "<a href='../submenu.html?key=agentHouse&id=" + obj.id + "'>" + (obj.houseNo?obj.houseNo:"无信息") + "</a>"
            return (obj.contractNo?obj.contractNo:"无信息");
        },
        "sTitle": "房源编号",
        "sDefaultContent": "",
        "sClass": "center"
    },{
        "mDataProp": function(obj) {
            return (!!obj.villageName?obj.villageName:"无信息")+'<br>'+(obj.houseAddress?obj.houseAddress:"无信息");
        },
        "sTitle": "小区/房源地址",
        "sDefaultContent": ""
    }, {
        "mDataProp": function (obj) {
            return (!!obj.agentName?obj.agentName:"无信息")+'&nbsp; / &nbsp;'+(obj.mobile?obj.mobile:"无信息");
        },
        "sTitle": "经纪人",
        "sDefaultContent": ""
    }, {
        "mDataProp": "createTime",
        "sTitle": "带看上传时间",
        "sDefaultContent": ""
    }, {
        "mDataProp": "point",
        "sTitle": "积分红包",
        "sDefaultContent": ""
    },{
        "mDataProp": function(obj) {
            return enumObject.getEnumValue("verifyStatus",obj.verifyStatus);
        },
        "sTitle": "审核状态",
        "sDefaultContent": "",
        "sClass": ""
    },{
        "mDataProp":"verifyTime",
        "sTitle": "审核时间",
        "sDefaultContent": "",
        "sClass": ""
    },{
        "mDataProp":function (obj) {
            var btn;
            var rst=obj.verifyStatus=="0";
            btn='<a href="javascript:;" class="record-info btn '+(rst?"btn-info":"btn-success")+'" data-id="'+obj.id+'" data-houseId="'+obj.houseId+'" data-status="'+obj.verifyStatus+'">'+(rst?"立即审核":"查看详情")+'</a>';
            return btn;
        },
        "sTitle": "操作",
        "sDefaultContent": "",
        "sClass": "text-center"
    }],
    "fnServerParams": function(aoData) {
        return common.getSearchData("form.data-list-search",aoData);
    }
};
var options = $.extend(true, {}, _dataTableSettings, settings);
/**
 * 实例化 中介联系人 列表插件
 * @type {[type]}
 */
var $currentDataTable=$("#data-list");
var oTable = $currentDataTable.dataTable(options);
searchList.getDataList(oTable);
searchList.resetSearch(oTable);
$currentDataTable.off("click",".record-info").on("click",".record-info",function (e) {
    var $this=$(this);
    var selfId=$this.attr("data-id");
    var selfHouseId=$this.attr("data-houseId");
    var selfStatus=$this.attr("data-status");
    common.openInsertDialog({
        title:'带看记录审核',
        url:"./creditManage/houseVisitedInfo.html?recordId="+selfId+"&houseId="+selfHouseId,
        'sAjaxSource': window.globalHost + common.houseVisitedVerifyPath,
        'area': ['1000px', '540px'],
        "btn":selfStatus=="0"?["保存","取消"]:[],
        ok: function() {
            //  新增信息成功之后，刷新列表页面
            oTable.fnClearTable();
        },
        cancel: function() {}
    });

});